﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ATM.Bussiness;
using ATM.Commons;

namespace ATM.UI
{
    public partial class MainSystem : Form
    {
        private BankMainSystem bnkMainSystemObject;
        private Untilities untiObject;
        public MainSystem()
        {
            InitializeComponent();
            pnlModifyValidate.Visible = false;
            pnlCreatCard.Visible = false;
            bnkMainSystemObject = new BankMainSystem();
            untiObject = new Untilities();
        }

        private void bntCreateATMCard_Click(object sender, EventArgs e)
        {
            pnlCreatCard.Visible = true;
            pnlWelcomeMain.Visible = false;
            pnlModifyValidate.Visible = false;
        }

        private void bntModify_Click(object sender, EventArgs e)
        {
            pnlCreatCard.Visible = false;
            pnlWelcomeMain.Visible = false;
            pnlModifyValidate.Visible = true;
        }

        private void bntValidateAccNumber_Click(object sender, EventArgs e)
        {
            bool validForm = untiObject.CheckRegexAccountNumber(txtAccNumber.Text);
            string strResult = "";
            string strAccNumber = txtAccNumber.Text;
            if(validForm && !string.IsNullOrEmpty(strAccNumber))
            {
                strResult = bnkMainSystemObject.ValidateAccNumber(txtAccNumber.Text);
                if (string.IsNullOrEmpty(strResult))
                {
                    lblSatusValidateAccNumber.Text = "Account Number Invalid !!!";
                }
                else
                {
                    txtName.Text = strResult;
                    txtCardID.Text = untiObject.CreatRandomCardID();
                    txtDayCreate.Text = DateTime.Today.Month+"/"+ DateTime.Today.Day+"/"+DateTime.Today.Year;
                    string strDateExpire = DateTime.Today.Month + "/" + DateTime.Today.Day + "/" + (DateTime.Today.Year+3);
                    txtDayExperie.Text = strDateExpire.ToString();
                }
            }
            else
            {
                lblSatusValidateAccNumber.Text = "Account Number Invalid !!!";
            }
            
        }

      

       

        

        
       

      
    }
}
